package com.beemans.admob.demo.ui.fragments

import android.view.View
import androidx.fragment.app.Fragment
import com.beemans.common.ext.init
import com.beemans.common.ui.fragments.CommonFragment
import com.beemans.admob.demo.R
import com.beemans.admob.demo.databinding.FragmentMainBinding
import com.tiamosu.databinding.delegate.lazyDataBindingOrNull
import com.tiamosu.databinding.page.DataBindingConfig

/**
 * @author tiamosu
 * @date 2020/7/5.
 */
class MainFragment : CommonFragment() {
    private val dataBinding: FragmentMainBinding? by lazyDataBindingOrNull { }

    private val fragments by lazy {
        arrayListOf<Fragment>().apply {
            add(NativeAdFragment())
            add(BannerAdFragment())
            add(SplashAdFragment())
            add(InsertAdFragment())
            add(RewardAdFragment())
        }
    }

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.fragment_main)
    }

    override fun initView(rootView: View?) {
        dataBinding?.mainViewPager
            ?.init(this, fragments, isUserInputEnabled = true)
            ?.let {
                dataBinding?.mainTabBarLayout?.setViewPager2(it)
            }
    }

    override fun doBusiness() {
    }
}